Namespace HBBSoft.Pivot
    <System.Serializable()> Public NotInheritable Class DimensionCollection
        Inherits System.Collections.CollectionBase

        Default Public Property Item(ByVal Index As Integer) As Dimension
            Get
                Return CType(List.Item(Index), Dimension)
            End Get
            Set(ByVal value As Dimension)
                List.Item(Index) = value
            End Set
        End Property

        Public Sub Add(ByRef value As Dimension)
            List.Add(value)
        End Sub

        Public Sub Insert(ByVal Index As Integer, ByRef value As Dimension)
            List.Insert(Index, value)
        End Sub

        Public Sub Remove(ByRef value As Dimension)
            List.Remove(value)
        End Sub

        Public Function Contains(ByRef value As Dimension) As Boolean
            Return List.Contains(value)
        End Function

        Public Function IndexOf(ByRef value As Dimension) As Integer
            Return List.IndexOf(value)
        End Function

        Friend Function GetByDimensionID(ByVal DimensionID As Integer) As Dimension
            Dim objDim As Dimension
            For Each objDim In Me.List
                While objDim IsNot Nothing
                    If objDim.ID = DimensionID Then
                        Return objDim
                    End If
                    objDim = objDim.Child
                End While
            Next
            Return Nothing
        End Function
    End Class
End Namespace
